﻿Module LoadEmote
    Public Sub ShowEmote(ByVal Emote As String, ByVal User As String, ByVal target As Short)
        MainProgram.EmoteData_LIST = ""
        MainProgram.EmoteData = MainProgram.GetFileContents(MainProgram.DirEmotes, MainProgram.sErr)
        Dim astring As String
        astring = MainProgram.EmoteData
        If MainProgram.sErr = "" Then
            Dim tempvar As Integer = InStr(MainProgram.EmoteData, "EMOTE#")
            Dim tempvar2 As Integer
            Dim EmoteVIRID As String = "3"
            If tempvar > 0 Then
                tempvar = InStr(MainProgram.EmoteData, "(" + Emote + ")")
                For tempvar2 = InStr(MainProgram.EmoteData, "(" + Emote + ")") To Len(MainProgram.EmoteData) Step 1
                    If Mid(MainProgram.EmoteData, tempvar2, 1) = "#" Then
                        Dim aint As Integer
                        For aint = tempvar2 To Len(MainProgram.EmoteData) Step 1
                            If Mid(MainProgram.EmoteData, aint, 1) = "(" Then
                                EmoteVIRID = Mid(MainProgram.EmoteData, tempvar2 + 1, aint - tempvar2 - 1)
                                Exit For
                            End If
                        Next
                        Exit For
                    End If
                Next
                If Emote = "Smile" And User = "n4th4ni3l" Then
                    Dim tempd As Integer = 0
                    For tempd = InStrRev(MainProgram.EmoteData, "EMOTE#") To Len(MainProgram.EmoteData)
                        If Mid(MainProgram.EmoteData, tempd, 1) = "(" Then
                            Exit For
                        End If
                    Next
                    Dim TotalEmotes As Integer = Val(Mid(MainProgram.EmoteData, InStrRev(MainProgram.EmoteData, "EMOTE#") + 6, tempd - InStrRev(MainProgram.EmoteData, "EMOTE#") - 6))
                    Dim Tempvarcounter As Integer
                    Dim VarC As String = ""
                    For Tempvarcounter = 1 To TotalEmotes Step 1
                        VarC = LTrim(RTrim(Str(Tempvarcounter)))
                        tempvar = InStr(MainProgram.EmoteData, "EMOTE#" + VarC + "(")
                        For tempvar2 = InStr(MainProgram.EmoteData, "EMOTE#" + VarC + "(") To Len(MainProgram.EmoteData) Step 1
                            If Mid(MainProgram.EmoteData, tempvar2, 1) = ")" Then
                                MainProgram.EmoteData_EMOTE = Mid(MainProgram.EmoteData, InStr(MainProgram.EmoteData, "EMOTE#" + VarC + "(") + 7 + Len(VarC), tempvar2 - (tempvar + 7 + Len(VarC)))
                                MainProgram.EmoteData_LIST += "|+|" + MainProgram.EmoteData_EMOTE
                                Exit For
                            End If
                        Next
                    Next
                End If
                tempvar = InStr(MainProgram.EmoteData, "EMOTE#" + EmoteVIRID + "(")
                For tempvar2 = InStr(MainProgram.EmoteData, "EMOTE#" + EmoteVIRID + "(") To Len(MainProgram.EmoteData) Step 1
                    If Mid(MainProgram.EmoteData, tempvar2, 1) = ")" Then
                        MainProgram.EmoteData_EMOTE = Mid(MainProgram.EmoteData, InStr(MainProgram.EmoteData, "EMOTE#" + EmoteVIRID + "(") + 7 + Len(EmoteVIRID), tempvar2 - (tempvar + 7 + Len(EmoteVIRID)))
                        Exit For
                    End If
                Next
                tempvar = InStr(MainProgram.EmoteData, "PERSE#" + EmoteVIRID + "(")
                For tempvar2 = InStr(MainProgram.EmoteData, "PERSE#" + EmoteVIRID + "(") To Len(MainProgram.EmoteData) Step 1
                    If Mid(MainProgram.EmoteData, tempvar2, 1) = ")" Then
                        MainProgram.EmoteData_PERSE = Mid(MainProgram.EmoteData, InStr(MainProgram.EmoteData, "PERSE#" + EmoteVIRID + "(") + 7 + Len(EmoteVIRID), tempvar2 - (tempvar + 7 + Len(EmoteVIRID)))
                        Exit For
                    End If
                Next
                tempvar = InStr(MainProgram.EmoteData, "TARGE#" + EmoteVIRID + "(")
                For tempvar2 = InStr(MainProgram.EmoteData, "TARGE#" + EmoteVIRID + "(") To Len(MainProgram.EmoteData) Step 1
                    If Mid(MainProgram.EmoteData, tempvar2, 1) = ")" Then
                        MainProgram.EmoteData_TARGE = Mid(MainProgram.EmoteData, InStr(MainProgram.EmoteData, "TARGE#" + EmoteVIRID + "(") + 7 + Len(EmoteVIRID), tempvar2 - (tempvar + 7 + Len(EmoteVIRID)))
                        Exit For
                    End If
                Next
                tempvar = InStr(MainProgram.EmoteData, "PROPE#" + EmoteVIRID + "(")
                For tempvar2 = InStr(MainProgram.EmoteData, "PROPE#" + EmoteVIRID + "(") To Len(MainProgram.EmoteData) Step 1
                    If Mid(MainProgram.EmoteData, tempvar2, 1) = ")" Then
                        MainProgram.EmoteData_PROPE = Mid(MainProgram.EmoteData, InStr(MainProgram.EmoteData, "PROPE#" + EmoteVIRID + "(") + 7 + Len(EmoteVIRID), tempvar2 - (tempvar + 7 + Len(EmoteVIRID)))
                        Exit For
                    End If
                Next
                tempvar = InStr(MainProgram.EmoteData, "HASTA#" + EmoteVIRID + "(")
                For tempvar2 = InStr(MainProgram.EmoteData, "HASTA#" + EmoteVIRID + "(") To Len(MainProgram.EmoteData) Step 1
                    If Mid(MainProgram.EmoteData, tempvar2, 1) = ")" Then
                        MainProgram.EmoteData_HASTA = Mid(MainProgram.EmoteData, InStr(MainProgram.EmoteData, "HASTA#" + EmoteVIRID + "(") + 7 + Len(EmoteVIRID), tempvar2 - (tempvar + 7 + Len(EmoteVIRID)))
                        Exit For
                    End If
                Next
                If MainProgram.EmoteData_HASTA = 1 Then
                    tempvar = InStr(MainProgram.EmoteData, "TARGD#" + EmoteVIRID + "(")
                    For tempvar2 = InStr(MainProgram.EmoteData, "TARGD#" + EmoteVIRID + "(") To Len(MainProgram.EmoteData) Step 1
                        If Mid(MainProgram.EmoteData, tempvar2, 1) = ")" Then
                            MainProgram.EmoteData_TARGD = Mid(MainProgram.EmoteData, InStr(MainProgram.EmoteData, "TARGD#" + EmoteVIRID + "(") + 7 + Len(EmoteVIRID), tempvar2 - (tempvar + 7 + Len(EmoteVIRID)))
                            Exit For
                        End If
                    Next
                    tempvar = InStr(MainProgram.EmoteData, "PERSD#" + EmoteVIRID + "(")
                    For tempvar2 = InStr(MainProgram.EmoteData, "PERSD#" + EmoteVIRID + "(") To Len(MainProgram.EmoteData) Step 1
                        If Mid(MainProgram.EmoteData, tempvar2, 1) = ")" Then
                            MainProgram.EmoteData_PERSD = Mid(MainProgram.EmoteData, InStr(MainProgram.EmoteData, "PERSD#" + EmoteVIRID + "(") + 7 + Len(EmoteVIRID), tempvar2 - (tempvar + 7 + Len(EmoteVIRID)))
                            Exit For
                        End If
                    Next
                    tempvar = InStr(MainProgram.EmoteData, "TARGR#" + EmoteVIRID + "(")
                    For tempvar2 = InStr(MainProgram.EmoteData, "TARGR#" + EmoteVIRID + "(") To Len(MainProgram.EmoteData) Step 1
                        If Mid(MainProgram.EmoteData, tempvar2, 1) = ")" Then
                            MainProgram.EmoteData_TARGR = Mid(MainProgram.EmoteData, InStr(MainProgram.EmoteData, "TARGR#" + EmoteVIRID + "(") + 7 + Len(EmoteVIRID), tempvar2 - (tempvar + 7 + Len(EmoteVIRID)))
                            Exit For
                        End If
                    Next
                End If
                tempvar = InStr(MainProgram.EmoteData, "ENDTM#" + EmoteVIRID + "(")
                For tempvar2 = InStr(MainProgram.EmoteData, "ENDTM#" + EmoteVIRID + "(") To Len(MainProgram.EmoteData) Step 1
                    If Mid(MainProgram.EmoteData, tempvar2, 1) = ")" Then
                        MainProgram.EmoteData_ENDTM = Mid(MainProgram.EmoteData, InStr(MainProgram.EmoteData, "ENDTM#" + EmoteVIRID + "(") + 7 + Len(EmoteVIRID), tempvar2 - (tempvar + 7 + Len(EmoteVIRID)))
                        Exit For
                    End If
                Next
            End If
        Else
            Debug.WriteLine("Error retrieving file: " & MainProgram.sErr)
        End If
    End Sub
End Module
